//主模块

// 把方法作为常量暴露出去

//state 状态：负责接收mutation状态-> 渲染render页面view
export const state = () => ({
    bNav: false,
    bLoading: false
  });
   
  //mutations 状态：接收actions状态（commit）-> mutate改变state，mutation 都是同步事务
  export const mutations = {
    M_UPDATE_NAV(state, payload) {
      state.bNav = payload;
    },
    M_UPDATE_LOADING(state, payload) {
      state.bLoading = payload;
    }
  }
   
  //actions 状态: 调用后台API接口，actions 是异步事务
  export const actions = {
    nuxtServerInit(store, {app:{$cookies}}) {
      //初始化token东西到store当中 
      let user = $cookies.get('userInfo') ? $cookies.get('userInfo') : {code:20001,message:'未登录',token:'',success:false,data: {}};
      store.commit('user/M_UPDATE_USER_INFO',user)
    }
  }
   
  //getters 状态： 接收state作为参数，用于计算、过滤等
  export const getters = {
    getNav(state){
      return state.bNav ? '显示' : '隐藏'
    }
  }